Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
@gram-data/gram-ast
Advanced tools
()-[define]->(ast)
Gram abstract syntax tree definitions, tokenizing regexes, and utilities like type guards.
npm install @gram-data/gram-ast
import { isGramSeq, isGramNode, isGramEdge } from '@gram-data/gram-ast';
import { toAST } from '@gram-data/gram-parse';
const src = '(a)-->(b)';
const parsed = toAST(src);
// the top-level of the AST is a sequence of paths
console.assert(isGramSeq(parsed));
// the first path should be an edge
const firstPath = parsed.children[0];
console.assert(isGramEdge(firstPath));
// the children of an edge are nodes
console.assert(isGramNode(firstPath.children[0]));
console.assert(isGramNode(firstPath.children[1]));
The gram
AST is based on the unist specification
for syntax trees. Many of the tools and techniques of the unified
ecosystem can be applied to working with gram
.
Gram represents data using two basic elements: paths and sequences.
Paths provide structure. Sequences provide order.
A gram
sequence is the root element of an AST.
It is exactly what it sounds like: a sequence of elements where
each element is a path.
The AST type is useful in returning a well-rooted tree that can be processed by general-purpose AST tools like unist-util-visit.
In practice this is equivalent to a GramPath[]
. Most gram
functions will accept either.
A gram
path is either an empty path, or the composition of two other paths.
The data structure of a path is like a list which remembers how it was assembled.
The list elements are other paths.
Each path has its own identity, labels and a data record.
In the AST, records are a multimap presented as an array of name/value properties. That means a property name may appear more than once, with different or the same values.
When mapping to a data model, choose one of these strageies for handling the multimapped properties:
FAQs
AST definitions for gram data graphs
The npm package @gram-data/gram-ast receives a total of 3 weekly downloads. As such, @gram-data/gram-ast popularity was classified as not popular.
We found that @gram-data/gram-ast demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.